#include "my_header.h"

#define MAX_PATH_LEN 1024
#define MAX_NAME_LEN 1024
#define MAX_QUERY_LEN 4096
typedef struct session_s{
    int curDirID;  //当前目录ID
    char username[MAX_NAME_LEN];  //用户名
    char curVirPath[MAX_PATH_LEN]; //当前虚拟路径 在pwd是能快速响应不用读表
}session_t;

typedef struct tlv_s{
    int type;
    int value_len;
    char value[1024];
}tlv_t;

//发 tlv小火车
int sendtlv(int netfd, char *buf);

//获得规范路径后的目录id
int make_id_path(session_t *session, MYSQL *mysql, const char *destDir, int *finalID);

//拿到真正所需参数名  有无参数+切割路径+所需名
int cut_path(session_t *session, MYSQL *mysql, const char*destDir, int *parentID, char *lastToken, char *buf, int bufLen);

//测试
int init_session(session_t *session, char *username, MYSQL *mysql);

//目录操作
int handle_pwd(session_t *session, char *buf, int bufLen);

int handle_ls(session_t *session, MYSQL *mysql, const char*destDir, char *buf, int bufLen);

int handle_cd(session_t *session, MYSQL *mysql, const char*destDir, char *buf, int bufLen);

int handle_mkdir(session_t *session, MYSQL *mysql, const char*destDir, char *buf, int bufLen);

int handle_remove(session_t *session, MYSQL *mysql, const char*fileName, char *buf, int bufLen);

int handle_rmdir(session_t *session, MYSQL *mysql, const char*destDir, char *buf, int bufLen);
